home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / WWW / Perl_WWW_Utilities / perlMIF_beta2 / mif / mif_pgfc.pl < prev    next >
Encoding:
Perl Script  |  1994-06-23  |  14.1 KB  |  486 lines

  1. ##---------------------------------------------------------------------------##
  2. ##  File:
  3. ##      mif_pgfc.pl
  4. ##  Author:
  5. ##      Earl Hood       ehood@convex.com
  6. ##  Description:
  7. ##    This file is defines the "mif_pgfc" perl package.  It defines
  8. ##    routines to handle the PgfCatalog via MIFread_mif() defined in
  9. ##    the "mif" package.
  10. ##---------------------------------------------------------------------------##
  11. ##  Copyright (C) 1994  Earl Hood, ehood@convex.com
  12. ##
  13. ##  This program is free software; you can redistribute it and/or modify
  14. ##  it under the terms of the GNU General Public License as published by
  15. ##  the Free Software Foundation; either version 2 of the License, or
  16. ##  (at your option) any later version.
  17. ## 
  18. ##  This program is distributed in the hope that it will be useful,
  19. ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ##  GNU General Public License for more details.
  22. ##  
  23. ##  You should have received a copy of the GNU General Public License
  24. ##  along with this program; if not, write to the Free Software
  25. ##  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. ##---------------------------------------------------------------------------##
  27.  
  28. require 'mif/mif.pl' || die "Unable to require mif.pl\n";
  29. require 'mif/mif_pgf.pl' || die "Unable to require mif_pgf.pl\n";
  30.  
  31. package mif_pgfc;
  32.  
  33. ##--------------------------------------------##
  34. ## Add PgfCatalog function to %MIFToken array ##
  35. ##--------------------------------------------##
  36. $mif'MIFToken{'PgfCatalog'} = 'PgfCatalog';
  37.  
  38. ##-------------------------------##
  39. ## PgfCatalog associative arrays ##
  40. ##-------------------------------##
  41. %PgfUseNextTag        = ();
  42. %PgfNextTag        = ();
  43. %PgfFIndent        = ();
  44. %PgfLIndent        = ();
  45. %PgfRIndent        = ();
  46. %PgfAlignment        = ();
  47. %PgfSpBefore        = ();
  48. %PgfSpAfter        = ();
  49. %PgfLineSpacing        = ();
  50. %PgfLeading        = ();
  51. %PgfNumTabs        = ();
  52. %TabStops        = ();
  53. %PgfPlacement        = ();
  54. %PgfPlacementStyle    = ();
  55. %PgfRunInDefaultPunct    = ();
  56. %PgfWithPrev        = ();
  57. %PgfWithNext        = ();
  58. %PgfBlockSize        = ();
  59. %PgfAutoNum        = ();
  60. %PgfNumFormat        = ();
  61. %PgfNumberFont        = ();
  62. %PgfNumAtEnd        = ();
  63. %PgfHyphenate        = ();
  64. %HyphenMaxLines        = ();
  65. %HyphenMinPrefix    = ();
  66. %HyphenMinSuffix    = ();
  67. %HyphenMinWord        = ();
  68. %PgfLetterSpace        = ();
  69. %PgfMinWordSpace    = ();
  70. %PgfOptWordSpace    = ();
  71. %PgfMaxWordSpace    = ();
  72. %PgfLanguage        = ();
  73. %PgfTopSeparator    = ();
  74. %PgfBotSeparator    = ();
  75. %PgfCellAlignment    = ();
  76. %PgfCellMargins        = ();
  77. %PgfCellLMarginFixed    = ();
  78. %PgfCellTMarginFixed    = ();
  79. %PgfCellRMarginFixed    = ();
  80. %PgfCellBMarginFixed    = ();
  81.  
  82. %FTag        = ();    # Tag name of font (should be "")
  83. %FFamily    = ();    # Name of font family
  84. %FAngle        = ();    # Name of angle
  85. %FWeight    = ();    # Name of weight
  86. %FVar        = ();    # Name of variation
  87. %FPostScriptName = ();    # Name of font sent to PostScript        # Frame 4.x
  88. %FPlatformName    = ();    # Platform-specific font name (Mac/Windows) # Frame 4.x
  89. %FSize        = ();    # Size in points
  90. %FColor        = ();    # Font color
  91. %FUnderline    = ();    # Underline boolean flag            # Frame 3.x
  92. %FDoubleUnderline = (); # DoubleUnderline boolean flag              # Frame 3.x
  93. %FNumericUnderline = ();# NumericUnderline boolean flag             # Frame 3.x
  94. %FUnderlining    = ();    # Underlining style                # Frame 4.x
  95. %FOverline    = ();    # Overline boolean flag
  96. %FStrike    = ();    # Strikethrough boolean flag
  97. %FSupScript    = ();    # Superscript boolean flag            # Frame 3.x
  98. %FSubScript    = ();    # Subscript boolean flag            # Frame 3.x
  99. %FChangeBar    = ();    # Change bar boolean flag
  100. %FPosition    = ();    # Sub/Superscript                # Frame 4.x
  101. %FOutline    = ();    # Outline boolean flag (Mac)
  102. %FShadow    = ();    # Shadow boolean flag (Mac)
  103. %FPairKern    = ();    # Pair kerning boolean flag
  104. %FCase        = ();    # Capitalization style                # Frame 4.x
  105. %FDX        = ();    # Horizontal manual kern value
  106. %FDY        = ();    # Vertical manual kern value
  107. %FDW        = ();    # Spread value for space between characters
  108. %FPlain        = ();    # Used only by filters
  109. %FBold        = ();    # Used only by filters
  110. %FItalic    = ();    # Used only by filters
  111. %FSeparation    = ();    # Spot color                    # Frame 3.x
  112.  
  113. ##------------------------##
  114. ## Import 'mif' variables ##
  115. ##------------------------##
  116. $MStore        = $mif'MStore;
  117. $MOpen        = $mif'MOpen;
  118. $MClose        = $mif'MClose;
  119. $MLine        = $mif'MLine;
  120. $mso        = $mif'mso;
  121. $msc        = $mif'msc;
  122. $stb        = $mif'stb;
  123. $ste        = $mif'ste;
  124. $como        = $mif'como;
  125.  
  126.                 ##---------------##
  127.                 ## Main Routines ##
  128.                 ##---------------##
  129. ##---------------------------------------------------------------------------
  130. ##    MIFwrite_pgfc() outputs the PgfCatalog as defined by the
  131. ##    associative arrays.
  132. ##
  133. ##    Usage:
  134. ##        &'MIFwrite_pgfc(FILEHANDLE);
  135. ##
  136. sub main'MIFwrite_pgfc {
  137.     local($handle, $l) = @_;
  138.     local($i0, $i1, $i2) = (' ' x $l, ' ' x (1+$l), ' ' x (2+$l));
  139.  
  140.     print $handle $i0, $mso, 'PgfCatalog', "\n";
  141.     foreach (sort keys %PgfUseNextTag) {
  142.     &'MIFwrite_pgf($handle, 1+$l,
  143.                $_,
  144.                $PgfUseNextTag{$_},
  145.                $PgfNextTag{$_},
  146.                $PgfFIndent{$_},
  147.                $PgfLIndent{$_},
  148.                $PgfRIndent{$_},
  149.                $PgfAlignment{$_},
  150.                $PgfSpBefore{$_},
  151.                $PgfSpAfter{$_},
  152.                $PgfLineSpacing{$_},
  153.                $PgfLeading{$_},
  154.                $PgfNumTabs{$_},
  155.                $TabStops{$_},
  156.                $PgfPlacement{$_},
  157.                $PgfPlacementStyle{$_},
  158.                $PgfRunInDefaultPunct{$_},
  159.                $PgfWithPrev{$_},
  160.                $PgfWithNext{$_},
  161.                $PgfBlockSize{$_},
  162.                $PgfAutoNum{$_},
  163.                $PgfNumFormat{$_},
  164.                $PgfNumberFont{$_},
  165.                $PgfNumAtEnd{$_},
  166.                $PgfHyphenate{$_},
  167.                $HyphenMaxLines{$_},
  168.                $HyphenMinPrefix{$_},
  169.                $HyphenMinSuffix{$_},
  170.                $HyphenMinWord{$_},
  171.                $PgfLetterSpace{$_},
  172.                $PgfMinWordSpace{$_},
  173.                $PgfOptWordSpace{$_},
  174.                $PgfMaxWordSpace{$_},
  175.                $PgfLanguage{$_},
  176.                $PgfTopSeparator{$_},
  177.                $PgfBotSeparator{$_},
  178.                $PgfCellAlignment{$_},
  179.                $PgfCellMargins{$_},
  180.                $PgfCellLMarginFixed{$_},
  181.                $PgfCellTMarginFixed{$_},
  182.                $PgfCellRMarginFixed{$_},
  183.                $PgfCellBMarginFixed{$_},
  184.                $FTag{$_},
  185.                $FFamily{$_},
  186.                $FAngle{$_},
  187.                $FWeight{$_},
  188.                $FVar{$_},
  189.                $FPostScriptName{$_},
  190.                $FPlatformName{$_},
  191.                $FSize{$_},
  192.                $FColor{$_},
  193.                $FUnderline{$_},
  194.                $FDoubleUnderline{$_},
  195.                $FNumericUnderline{$_},
  196.                $FUnderlining{$_},
  197.                $FOverline{$_},
  198.                $FStrike{$_},
  199.                $FSupScript{$_},
  200.                $FSubScript{$_},
  201.                $FChangeBar{$_},
  202.                $FPosition{$_},
  203.                $FOutline{$_},
  204.                $FShadow{$_},
  205.                $FPairKern{$_},
  206.                $FCase{$_},
  207.                $FDX{$_},
  208.                $FDY{$_},
  209.                $FDW{$_},
  210.                $FPlain{$_},
  211.                $FBold{$_},
  212.                $FItalic{$_},
  213.                $FSeparation{$_});
  214.     }
  215.     print $handle $i0, $msc, " $como end of PgfCatalog\n";
  216. }
  217. ##---------------------------------------------------------------------------##
  218. ##    MIFget_ptag_data() is a convienence routine that returns
  219. ##    data associated with the para tag $ptag.  The font data returned
  220. ##    is specific to MIF version 4.x, except it will also return the
  221. ##    FSeparation value.
  222. ##
  223. ##    Usage:
  224. ##        (<pgf data> ...,
  225. ##         $ftag, $family, $angle, $weight, $var, $size, $undlining,
  226. ##         $overline, $strike, $chngbar, $position, $outline, $shadow,
  227. ##         $pairkern, $case, $dx, $dy, $dw, $color, $separation)
  228. ##        =
  229. ##        &'MIFget_ptag_data($ptag);
  230. ##
  231. sub main'MIFget_ptag_data {
  232.     local($ptag) = @_;
  233.     ($PgfUseNextTag{$ptag},
  234.      $PgfNextTag{$ptag},
  235.      $PgfFIndent{$ptag},
  236.      $PgfLIndent{$ptag},
  237.      $PgfRIndent{$ptag},
  238.      $PgfAlignment{$ptag},
  239.      $PgfSpBefore{$ptag},
  240.      $PgfSpAfter{$ptag},
  241.      $PgfLineSpacing{$ptag},
  242.      $PgfLeading{$ptag},
  243.      $PgfNumTabs{$ptag},
  244.      $TabStops{$ptag},
  245.      $PgfPlacement{$ptag},
  246.      $PgfPlacementStyle{$ptag},
  247.      $PgfRunInDefaultPunct{$ptag},
  248.      $PgfWithPrev{$ptag},
  249.      $PgfWithNext{$ptag},
  250.      $PgfBlockSize{$ptag},
  251.      $PgfAutoNum{$ptag},
  252.      $PgfNumFormat{$ptag},
  253.      $PgfNumberFont{$ptag},
  254.      $PgfNumAtEnd{$ptag},
  255.      $PgfHyphenate{$ptag},
  256.      $HyphenMaxLines{$ptag},
  257.      $HyphenMinPrefix{$ptag},
  258.      $HyphenMinSuffix{$ptag},
  259.      $HyphenMinWord{$ptag},
  260.      $PgfLetterSpace{$ptag},
  261.      $PgfMinWordSpace{$ptag},
  262.      $PgfOptWordSpace{$ptag},
  263.      $PgfMaxWordSpace{$ptag},
  264.      $PgfLanguage{$ptag},
  265.      $PgfTopSeparator{$ptag},
  266.      $PgfBotSeparator{$ptag},
  267.      $PgfCellAlignment{$ptag},
  268.      $PgfCellMargins{$ptag},
  269.      $PgfCellLMarginFixed{$ptag},
  270.      $PgfCellTMarginFixed{$ptag},
  271.      $PgfCellRMarginFixed{$ptag},
  272.      $PgfCellBMarginFixed{$ptag},
  273.      $FTag{$ptag},
  274.      $FFamily{$ptag},
  275.      $FAngle{$ptag},
  276.      $FWeight{$ptag},
  277.      $FVar{$ptag},
  278.      $FSize{$ptag},
  279.      $FUnderlining{$ptag},
  280.      $FOverline{$ptag},
  281.      $FStrike{$ptag},
  282.      $FChangeBar{$ptag},
  283.      $FPosition{$ptag},
  284.      $FOutline{$ptag},
  285.      $FShadow{$ptag},
  286.      $FPairKern{$ptag},
  287.      $FCase{$ptag},
  288.      $FDX{$ptag},
  289.      $FDY{$ptag},
  290.      $FDW{$ptag},
  291.      $FColor{$ptag},
  292.      $FSeparation{$ptag});
  293. }
  294. ##---------------------------------------------------------------------------##
  295. ##      MIFget_ptags() returns a sorted array of all paragraph tag names
  296. ##      defined in the paragraph catalog.
  297. ##
  298. ##      Usage:
  299. ##          @ptags = &'MIFget_ptags();
  300. ##
  301. sub main'MIFget_ptags {
  302.      return sort keys %PgfUseNextTag;
  303. }
  304. ##---------------------------------------------------------------------------##
  305. ##    MIFreset_pgfc() resets all the associative arrays defining the
  306. ##    paragraph catalog.
  307. ##
  308. sub main'MIFreset_pgfc {
  309.     undef %PgfUseNextTag;
  310.     undef %PgfNextTag;
  311.     undef %PgfFIndent;
  312.     undef %PgfLIndent;
  313.     undef %PgfRIndent;
  314.     undef %PgfAlignment;
  315.     undef %PgfSpBefore;
  316.     undef %PgfSpAfter;
  317.     undef %PgfLineSpacing;
  318.     undef %PgfLeading;
  319.     undef %PgfNumTabs;
  320.     undef %TabStops;
  321.     undef %PgfPlacement;
  322.     undef %PgfPlacementStyle;
  323.     undef %PgfRunInDefaultPunct;
  324.     undef %PgfWithPrev;
  325.     undef %PgfWithNext;
  326.     undef %PgfBlockSize;
  327.     undef %PgfAutoNum;
  328.     undef %PgfNumFormat;
  329.     undef %PgfNumberFont;
  330.     undef %PgfNumAtEnd;
  331.     undef %PgfHyphenate;
  332.     undef %HyphenMaxLines;
  333.     undef %HyphenMinPrefix;
  334.     undef %HyphenMinSuffix;
  335.     undef %HyphenMinWord;
  336.     undef %PgfLetterSpace;
  337.     undef %PgfMinWordSpace;
  338.     undef %PgfOptWordSpace;
  339.     undef %PgfMaxWordSpace;
  340.     undef %PgfLanguage;
  341.     undef %PgfTopSeparator;
  342.     undef %PgfBotSeparator;
  343.     undef %PgfCellAlignment;
  344.     undef %PgfCellMargins;
  345.     undef %PgfCellLMarginFixed;
  346.     undef %PgfCellTMarginFixed;
  347.     undef %PgfCellRMarginFixed;
  348.     undef %PgfCellBMarginFixed;
  349.  
  350.     undef %FTag;
  351.     undef %FFamily;
  352.     undef %FAngle;
  353.     undef %FWeight;
  354.     undef %FVar;
  355.     undef %FPostScriptName;
  356.     undef %FPlatformName;
  357.     undef %FSize;
  358.     undef %FColor;
  359.     undef %FUnderline;
  360.     undef %FDoubleUnderline;
  361.     undef %FNumericUnderline;
  362.     undef %FUnderlining;
  363.     undef %FOverline;
  364.     undef %FStrike;
  365.     undef %FSupScript;
  366.     undef %FSubScript;
  367.     undef %FChangeBar;
  368.     undef %FPosition;
  369.     undef %FOutline;
  370.     undef %FShadow;
  371.     undef %FPairKern;
  372.     undef %FCase;
  373.     undef %FDX;
  374.     undef %FDY;
  375.     undef %FDW;
  376.     undef %FPlain;
  377.     undef %FBold;
  378.     undef %FItalic;
  379.     undef %FSeparation;
  380. }
  381. ##---------------------------------------------------------------------------##
  382.                 ##--------------##
  383.                 ## Mif Routines ##
  384.                 ##--------------##
  385. ##---------------------------------------------------------------------------##
  386. ##    The routines definded below are all registered in the %MIFToken         ##
  387. ##    array for use in the MIFread_mif() routine.  There purpose is to     ##
  388. ##    store the information contained in the paragraph catalog.         ##
  389. ##---------------------------------------------------------------------------##
  390.  
  391. ##---------------------------------------------------------------------------
  392. ##    PgfCatalog() is the token routine for 'PgfCatalog'.
  393. ##    It sets/restores token routines depending upon mode.
  394. ##
  395. sub mif'PgfCatalog {
  396.     local($token, $mode, *data) = @_;
  397.     if ($mode == $MOpen) {
  398.     ($_fast, $_noidata) = ($mif'fast, $mif'no_import_data);
  399.     ($mif'fast, $mif'no_import_data) = (1, 1);
  400.     $_pgf_orgfunc = &'MIFget_pgf_func();
  401.     &'MIFset_pgf_func("mif_pgfc'pgf_close");
  402.     } elsif ($mode == $MClose) {
  403.     &'MIFset_pgf_func($_pgf_orgfunc);
  404.         ($mif'fast, $mif'no_import_data) = ($_fast, $_noidata);
  405.     }
  406. }
  407. ##---------------------------------------------------------------------------
  408. sub pgf_close {
  409.     local($tag, $tmp);
  410.     $tag = $mif_pgf'pgf_Tag;
  411.   
  412.     ($tmp,
  413.      $PgfUseNextTag{$tag},
  414.      $PgfNextTag{$tag},
  415.      $PgfFIndent{$tag},
  416.      $PgfLIndent{$tag},
  417.      $PgfRIndent{$tag},
  418.      $PgfAlignment{$tag},
  419.      $PgfSpBefore{$tag},
  420.      $PgfSpAfter{$tag},
  421.      $PgfLineSpacing{$tag},
  422.      $PgfLeading{$tag},
  423.      $PgfNumTabs{$tag},
  424.      $TabStops{$tag},
  425.      $PgfPlacement{$tag},
  426.      $PgfPlacementStyle{$tag},
  427.      $PgfRunInDefaultPunct{$tag},
  428.      $PgfWithPrev{$tag},
  429.      $PgfWithNext{$tag},
  430.      $PgfBlockSize{$tag},
  431.      $PgfAutoNum{$tag},
  432.      $PgfNumFormat{$tag},
  433.      $PgfNumberFont{$tag},
  434.      $PgfNumAtEnd{$tag},
  435.      $PgfHyphenate{$tag},
  436.      $HyphenMaxLines{$tag},
  437.      $HyphenMinPrefix{$tag},
  438.      $HyphenMinSuffix{$tag},
  439.      $HyphenMinWord{$tag},
  440.      $PgfLetterSpace{$tag},
  441.      $PgfMinWordSpace{$tag},
  442.      $PgfOptWordSpace{$tag},
  443.      $PgfMaxWordSpace{$tag},
  444.      $PgfLanguage{$tag},
  445.      $PgfTopSeparator{$tag},
  446.      $PgfBotSeparator{$tag},
  447.      $PgfCellAlignment{$tag},
  448.      $PgfCellMargins{$tag},
  449.      $PgfCellLMarginFixed{$tag},
  450.      $PgfCellTMarginFixed{$tag},
  451.      $PgfCellRMarginFixed{$tag},
  452.      $PgfCellBMarginFixed{$tag},
  453.      $FTag{$tag},
  454.      $FFamily{$tag},
  455.      $FAngle{$tag},
  456.      $FWeight{$tag},
  457.      $FVar{$tag},
  458.      $FPostScriptName{$tag},
  459.      $FPlatformName{$tag},
  460.      $FSize{$tag},
  461.      $FColor{$tag},
  462.      $FUnderline{$tag},
  463.      $FDoubleUnderline{$tag},
  464.      $FNumericUnderline{$tag},
  465.      $FUnderlining{$tag},
  466.      $FOverline{$tag},
  467.      $FStrike{$tag},
  468.      $FSupScript{$tag},
  469.      $FSubScript{$tag},
  470.      $FChangeBar{$tag},
  471.      $FPosition{$tag},
  472.      $FOutline{$tag},
  473.      $FShadow{$tag},
  474.      $FPairKern{$tag},
  475.      $FCase{$tag},
  476.      $FDX{$tag},
  477.      $FDY{$tag},
  478.      $FDW{$tag},
  479.      $FPlain{$tag},
  480.      $FBold{$tag},
  481.      $FItalic{$tag},
  482.      $FSeparation{$tag}) = &'MIFget_last_pgf_data();
  483. }
  484. ##---------------------------------------------------------------------------
  485. 1;
  486.